 /**
   * Copyright 2014 Viettel Telecom. All rights reserved.
   * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
   */
 package com.viettel.core.dao.cms; 
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.viettel.core.entities.cms.ExpertGroup;
import com.viettel.core.entities.cms.ExpertTechnique;
import com.viettel.core.enumtype.ExpertTechniqueStatus;
import com.viettel.core.exceptions.DataAccessException;
import com.viettel.core.repo.IRepository;
 /**
   *  Mo ta muc dich cua lop (interface)
   *  @author: HUYNHDC
   *  @version:  
   *  @since: 24/06/2014 - 10:50:59
   */
 public class ExpertTechniqueDAOImpl implements ExpertTechniqueDAO { 
	 private IRepository repo; 
		
	 	public void setRepo(IRepository repo) {
			this.repo = repo;
		}
 
	 /**
	   *  Mo ta muc dich cua lop (interface)
	   *  @author: HUYNHDC
	   *  @version:  
	   *  @since: 24/06/2014 - 10:50:59
	   */
 	@Override 
	public ExpertTechnique getExpertTechniqueById(Integer id) throws DataAccessException { 
		return repo.getEntityById(ExpertTechnique.class, id); 
	} 
 
 	 /**
 	   *  Mo ta muc dich cua lop (interface)
 	   *  @author: HUYNHDC
 	   *  @version:  
 	   *  @since: 24/06/2014 - 10:50:59
 	   */
 	@Override 
	public ExpertTechnique createExpertTechnique(ExpertTechnique expertTechnique) 
			throws DataAccessException { 
		if (expertTechnique == null) { 
			throw new IllegalArgumentException("experttechnique"); 
		} 
		repo.create(expertTechnique); 
		return repo.getEntityById(ExpertTechnique.class, expertTechnique.getId()); 
	} 
 	 /**
 	   *  Mo ta muc dich cua lop (interface)
 	   *  @author: HUYNHDC
 	   *  @version:  
 	   *  @since: 24/06/2014 - 10:50:59
 	   */
 	@Override 
	public void updateExpertTechnique(ExpertTechnique expertTechnique) throws DataAccessException { 
		if (expertTechnique == null) { 
			throw new IllegalArgumentException("experttechnique"); 
		} 
		repo.update(expertTechnique); 
	} 
 	 /**
 	   *  Mo ta muc dich cua lop (interface)
 	   *  @author: HUYNHDC
 	   *  @version:  
 	   *  @since: 24/06/2014 - 10:50:59
 	   */
 	@Override 
	public void deleteExpertTechnique(ExpertTechnique expertTechnique) throws DataAccessException { 
		if (expertTechnique == null) { 
			throw new IllegalArgumentException("experttechnique"); 
		} 
		repo.delete(expertTechnique); 
	}
 
 	/**
	   *  
	   *  @author: HUYNHDC
	   *  @version:  
	   *  @since: 24/06/2014 - 10:50:59
	   */
	@Override 
	public List<ExpertTechnique> lstExpertTechniqueByCmsUserId(Integer id) throws DataAccessException { 
		List<Object> params = new ArrayList<Object>();
		String sql = "SELECT * FROM EXPERT_TECHNIQUE  where CMS_USERS_ID = ? AND STATUS != ?";
		params.add(id);
		params.add(ExpertTechniqueStatus.DELETED.getValue());
		return repo.getListBySQL(ExpertTechnique.class, sql, params);
	} 
	
	/**
	   *  
	   *  @author: HUYNHDC
	   *  @version:  
	   *  @since: 24/06/2014 - 10:50:59
	   */
	@Override 
	public List<ExpertTechnique> lstExpertTechniqueByTechniqueId(Integer id) throws DataAccessException { 
		List<Object> params = new ArrayList<Object>();
		String sql = "SELECT * FROM EXPERT_TECHNIQUE  where TECHNIQUE_CATEGORY_ID = ? AND STATUS != ?";
		params.add(id);
		params.add(ExpertTechniqueStatus.DELETED.getValue());
		return repo.getListBySQL(ExpertTechnique.class, sql, params);
	} 

	 /**
	   * 
	   *  @author: HUYNHDC
	   *  @version:  
	   *  @since: 24/06/2014 - 10:50:59
	   */
	@Override 
	public void deleteExpertTechniqueByCmsUserId(Integer id) throws DataAccessException { 
		List<Object> params = new ArrayList<Object>();
		String sql = "UPDATE EXPERT_TECHNIQUE SET status = ? WHERE cms_users_id = ?";
		params.add(ExpertTechniqueStatus.DELETED.getValue());
		params.add(id);
		repo.executeSQLQuery(sql, params);
	} 

} 
 
